home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14490 < prev    next >
Encoding:
Text File  |  1996-08-05  |  993 b   |  39 lines

  1. Path: inforamp.net!ts13-05
  2. From: rmorin@inforamp.net (Randy Charles Morin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Help Please
  5. Date: Sat, 30 Mar 96 20:46:02 GMT
  6. Organization: MiddleWorld SoftWare
  7. Message-ID: <4jk6j3$l58@sam.inforamp.net>
  8. References: <4ji7eo$kgm@daisy.flex.com.au>
  9. NNTP-Posting-Host: ts13-05.tor.istar.ca
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. In article <4ji7eo$kgm@daisy.flex.com.au>, cobweb@flex.com.au (Tony L) wrote:
  13. >main()
  14. >{
  15. >    char him[] = "Keating";
  16. ..
  17. >    scanf("  %s", last2);
  18. >    if (last2 == him)
  19. >        { printf("you have voted for Paul Keating!"); }
  20.  
  21. You are are comparing a char * to a char *.  This means you are
  22. comparing a pointer to another pointer.  That is, the address
  23. of the string, not the string.  You want to use the string 
  24. function strcmp.
  25.     if (strcmp(last2, him)==0)
  26.         { printf("you have voted for Paul Keating!"); }
  27.  
  28. Hope I've helped.
  29.  
  30. Agrivar
  31.  
  32.  
  33. Agrivar
  34.  
  35. aka     Randy Charles Morin
  36.     MiddleWorld SoftWare
  37.     Canada: 1-800-363-3780
  38.     Other:    905-279-2087
  39.